home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7990 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: anvil.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Need Unique Id generation.
  5. Date: 28 Feb 1996 12:09:25 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4h2cplINNhsi@anvil.ugrad.cs.ubc.ca>
  8. References: <4h1v2g$btc@alpha.it.net>
  9. NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
  10.  
  11. In article <4h1v2g$btc@alpha.it.net>,
  12. Antonio Romeo <gema001@pn.itnet.it> wrote:
  13.  >I need a Unique Identifier generation routine on multiple machines.
  14.  >The identifier must be a 32bit long (unsigned long int) number.
  15.  >No two identifier generated on different machines can match. 
  16.  
  17. Pick a number. This should be larger than the expected number of
  18. machines. Make it a power of two so you can strength reduce the modulo
  19. operation to bit masking.
  20.  
  21. Assign a unique _congruence class_ modulo that number to each machine.
  22. Write a routine that, on any machine, picks identifiers only from that
  23. congruence class. For example, if the modulus is 32, and the machine "foo" is
  24. congruence class 3 (modulo 32), it will generate numbers that yield a remainder
  25. of 3 when divided by 32. I.e. ones with a bit pattern:
  26.  
  27.     xxxxxxxxx00011
  28.  
  29. Where the x's are the rest of the identifier. The lower portion can be thought
  30. of as a machine identifier.
  31.  
  32.  >This is different from an hash generation as i don't have
  33.  >any 'imput string for it.
  34.  >A clock based only algorithm is not usefull, as two machines
  35.  >can generate the same UI at the same time.
  36.  >So I need a routine based on clock and some machine identifier too.
  37.  >
  38.  >Rule:
  39.  >1. UIs generated on two machines or in different time must be 
  40.  >differento from every UI already used;
  41.  
  42. Each machine can ensure this. The x's can be randomly obtained from the BSD
  43. random() function or the standard  rand() (which has horrible properties :).
  44.  
  45.  >Thank for your help
  46.  
  47. You can also write a central ``identifier server''. Clients will send requests
  48. to this server to obtain a unique identifier. The server will generate a
  49. network-wide unique ID and send it back as the reply. Of course,then you have
  50. to deal with:
  51.  
  52.     1.    failure of the server
  53.     2.    failure of clients to return ID's (this should not be a
  54.         problem with such a large ID space).
  55. -- 
  56.  
  57.